package algorithms.hint;
import storage.Block;
import configuration.Configuration;
/**
* @author Nodirjon Siddikov
*/
public class LocalCacheBlock
{
private int _size;
private boolean _isMaster;
private Block _diskBlock; //pointer to the disk block that this cache block is hosting
private long _lastAccessTimestamp;
//constructor
public LocalCacheBlock(Block block, boolean isMaster)
{
_diskBlock = block;
_size = _diskBlock.getSize() + Configuration.tagSize;
_isMaster = isMaster;
_lastAccessTimestamp = System.currentTimeMillis();
}
//get disk block ID
public int getDiskBlockID()
{
return _diskBlock.getID();
}
//gets the disk block
public Block getDiskBlock()
{
return _diskBlock;
}
//check if the block is master copy
public boolean isMasterCopy()
{
return _isMaster;
}
//set as a master copy
public void setAsMasterCopy()
{
_isMaster = true;
}
//get the size of the cache block
public int getSize()
{
return _size;
}
//get last access timestamp
public long getLastAccessTimestamp()
{
return _lastAccessTimestamp;
}
//set last access timestamp
public void setLastAccessTimestamp(long newTimestamp)
{
_lastAccessTimestamp = newTimestamp;
}
}